package xddq

import (
	"fmt"
	"time"
	D "websocket_apn/define"
	"websocket_apn/log"
	"websocket_apn/proto"
)

/*
[DEBUG] [2025/01/03 21:39:21] [PRJ/websocket_apn/main_test.go]:[  197]:   ↑↑↑↑↑ S_GUARD_FAIRY_TREE_FIGHT_RESULT - len:36 3 1成功
[DEBUG] [2025/01/03 21:39:21] [PRJ/websocket_apn/main_test.go]:[  204]:   PayloadBytes: 71 AB 00 00 00 24 00 03 50 DD 00 00 02D4 07 01 81 E2 08 F7 DD F8 04 10 B1 EA 01 20 01 2A 05 08 B0 09 20 03
*/
//解析守卫仙树
func (xd *XdDriver) CheckGuardFairyTreeInfoData(info D.GuardFairyTreeInfo) {
	level := proto.ParaIntDataByHexStr(info.Level)
	if level%10000 == 5 || level%10000 == 10 || level%10000 == 15 {
		xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_GUARD_FAIRY_TREE_SET_WEAPON, fmt.Sprintf("08 %s 10 E9 07 10 EB 07 10 EC 07 10 EE 07 10 EF 07 10 F0 07 10 F1 07 10 F2 07 18 %s", xd.UserData.Activity[D.Activity_Guard_Fairy_Tree].ID, info.NowLevel)))
		xd.ResetTaskByID(proto.S_GUARD_FAIRY_TREE_ENTER_ACTIVITY)
	}
	if info.Now > 0 {
		if info.NowLevel == "00" {
			log.Infof("守卫仙树-当前第%d关 已通关", info.Now)
		} else {
			log.Infof("守卫仙树-当前第%d关 %d小关", info.Now, proto.ParaIntDataByHexStr(info.NowLevel)%10000)
			xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_GUARD_FAIRY_TREE_FIGHT_RESULT, fmt.Sprintf("08 %s 10 %s 20 01 2A 06 08 80 F7 01 20 03", xd.UserData.Activity[D.Activity_Guard_Fairy_Tree].ID, info.NowLevel)))
			time.Sleep(1 * time.Second)
			xd.ResetTaskByID(proto.S_GUARD_FAIRY_TREE_ENTER_ACTIVITY)
		}
	}
}
